<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<div id="container">
<p contenteditable id="sample">01234567</p>
<button id="button">This is a button</button>
</div>
<script>
description('Selection should be kept after focus changed.');
var selection = getSelection();
var sample = document.getElementById('sample').firstChild;
selection.collapse(sample, 3);
selection.extend(sample, 6);
document.getElementById('button').focus();
shouldBe('selection.anchorNode', 'sample');
shouldBe('selection.anchorOffset', '3');
shouldBe('selection.focusNode', 'sample');
shouldBe('selection.focusOffset', '6');
document.getElementById('container').outerHTML = '';
</script>
